<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('评价志愿者')" />
</head>
<style>
    body {
        position: relative;
    }
</style>

<body class="gray-bg" id="parentBody">

    <div class="container-div">
        <div class="row">
            <!--    搜索模块    -->
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <p>志愿者编号：</p>
                                <input type="text" name="volunteerCode"/>
                            </li>
                            <li>
                                <p>姓名：</p>
                                <input type="text" name="volunteerName"/>
                            </li>

                            <li>
                                <a class="btn btn-success btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>搜索</a>
                                <a class="btn btn-warning btn-sm" onclick="reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                    <!--    额外搜索条件   -->
                    <input name="appraiseState" id="appraiseState" value="1" style="display: none"/>
                </form>
            </div>

            <!--    功能模块    -->
            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-white" onclick="wei()">未评价</a>
                <a class="btn btn-white" onclick="yi()">已评价</a>
            </div>


            <!--    信息表格    -->
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table">
                    <thead>
                    <tr>
                        <th data-checkbox="true"></th>
                        <th data-formatter="fm_rowIndex" data-align="center">序号</th>
                        <th data-field="volunteerCode" data-align="center">志愿者编号</th>
                        <th data-field="volunteerName">姓名</th>
                        <th data-field="sectorName">部门</th>
                        <th data-field="sexName">性别</th>
                        <th data-field="volunteerLevel">年级</th>
                        <th data-field="volunteerAcademy">学院</th>
                        <th data-field="volunteerProfession">专业</th>
                        <th data-field="postName">服务岗位</th>
                        <th data-formatter="fm_commands" data-width="120px" data-align="center">操作</th>
                    </tr>
                    </thead>
                </table>
            </div>
        </div>
    </div>

    <th:block th:include="include :: footer" />
    <script id="parent-script" th:inline="javascript">
        /** 初始配置——路径配置，字典配置 */
        var prefix = ctx + "vtsp/volunteer";

        //  路径变量初始化
        $(function() {
            var options = {
                url: prefix + "/list/[[${activityId}]]",
                updateUrl: prefix + "/edit/{id}",
                modalName: "志愿者信息",
                uniqueId: "volunteerId"
            };
            $.table.init(options);
        });

        //  学历字典数据
        let degree_dict = [[${@dict.getType('degree')}]];
        //  根据字典的学历格式转化器
        function fm_degree(value, row ,index) {
            return $.table.selectDictLabel(degree_dict, value);
        }

        //  学院字典数据
        let academy_dict = [[${@dict.getType('academy')}]];
        //  根据字典的学院格式转化器
        function fm_academy(value, row ,index) {
            return $.table.selectDictLabel(academy_dict, value);
        }

        //  命令
        function fm_commands(value, row, index){
            var actions = [];
            console.log(row.appraiseState)
            if (row.appraiseState === 2) {
                actions.push('<a class="btn btn-success btn-xs " href="javascript:void(0)" onclick="appraise1(\'' + row.volunteerId + '\')">评价</a> ');
            } else {
                actions.push('<a class="btn btn-success btn-xs " href="javascript:void(0)" onclick="appraise(\'' + row.volunteerId + '\')">评价</a> ');
            }
            return actions.join('');
        }

        //  查询审核通过的志愿者信息
        function yi() {
          let node = document.getElementById("appraiseState");
          node.setAttribute("value", "2");
          $.table.search();
        }

        //  查询审核不通过的志愿者信息
        function wei() {
          let node = document.getElementById("appraiseState");
          node.setAttribute("value", "1");
          $.table.search();
        }

        function appraise1(id) {
            var url = prefix + '/appraiseModel2/[[${activityId}]]/' + id;
            $.modal.open("评价", url);
        }
        function appraise(id) {
            var url = prefix + '/appraiseModel/[[${activityId}]]/' + id;
            $.modal.open("评价", url);
        }
        //  重置全部的选择条件，
        function reset() {
            let node = document.getElementById("chooseMemberState");
            node.setAttribute("value", "");
            $.form.reset();
        }

    </script>
</body>
</html>
